#ifndef ARRAYTP_H_
#define ARRAYTP_H_

#include <iostream>
#include <cstring>

template <class T,int n>
class ArrayTp
{
private:
    T items_[n];
public:
    explicit ArrayTp(const T &v) ;
    ArrayTp(){};
    virtual T & operator[](int i);
    virtual T operator[](int i) const;
};
template <class T,int n>
ArrayTp<T,n>::ArrayTp(const T &v)
{
    for(int i = 0; i < n; i++)
        items_[i] = v;
};

template <class T,int n>
T & ArrayTp<T,n>::operator[](int i)
{
    if (i < 0 || i >= n)
    {
        std::cout << "Error in ArrayTp<T,n>::operator[](int i)\n";
        std::cout << "Index out of bounds\n";
        std::exit(EXIT_FAILURE);
    }
    return items_[i];
};

template <class T,int n>
T ArrayTp<T,n>::operator[](int i) const
{
    if (i < 0 || i >= n)
    {
        std::cout << "Error in ArrayTp<T,n>::operator[](int i)\n";
        std::cout << "Index out of bounds\n";
        std::exit(EXIT_FAILURE);
    }
    return items_[i];
}
#endif


